package com.shrct.businessprocess.purchase.impl;

import com.google.common.base.Objects;
import com.shrct.businessprocess.product.RCProductEntry;
import com.shrct.businessprocess.product.RCProductSpecification;
import com.shrct.businessprocess.purchase.RCIdentifiableProductDeliverItem;
import com.shrct.businessprocess.purchase.RCProductDeliver;
import com.shrct.businessprocess.purchase.impl.RCProductDeliverItemImpl;
import com.shrct.businessprocess.purchase.proxy.RCIdentifiableProductDeliverItemProxy;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

@Entity
@DiscriminatorValue("RCIDENTIFIABLEPRODUCTDELIVERITEM_TYPE")
public abstract class RCIdentifiableProductDeliverItemImpl extends RCProductDeliverItemImpl implements RCIdentifiableProductDeliverItem {
  public RCIdentifiableProductDeliverItemImpl() {
    super();
  }
  
  public RCIdentifiableProductDeliverItemImpl(final RCProductDeliver deliver) {
    super( deliver);
    
  }
  
  private Integer quantity = Integer.valueOf(1);
  
  public Integer getQuantity() {
    return this.quantity;
  }
  
  public RCIdentifiableProductDeliverItem setQuantity(final Integer quantity) {
    this.quantity = quantity;
    return this;			
    
  }
  
  public Integer getDeliveredQuantity() {
    int _xifexpression = (int) 0;
    boolean _equals = Objects.equal(this.quantity, null);
    if (_equals) {
      _xifexpression = 1;
    } else {
      _xifexpression = this.quantity;
    }
    return Integer.valueOf(_xifexpression);
  }
  
  public RCProductSpecification getProductSpec() {
    RCProductEntry _product = this.getProduct();
    RCProductSpecification _type = _product.getType();
    return _type;
  }
  
  public RCIdentifiableProductDeliverItemProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCIdentifiableProductDeliverItemProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCIdentifiableProductDeliverItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
